import Base from '../utils/base.js'
class Home extends Base {
  constructor() {
    super();
  }
 
  getCatData(callBacks) {
    this.request({
      url: '/cat',
      callback: function (res) {
        if (res.status === 1) {
          typeof callBacks === 'function' ? callBacks(res.data) : '';
        }

      }
    })
  }
  getPositions(page, size, callBacks) {
    this.request({
      url: '/positions',
      data: {
        page: page,
        size: size,
      },
      callback: function (res) {
        if (res.status === 1) {
          typeof callBacks === 'function' ? callBacks(res.data) : '';
        }

      }
    })
  }
  getSearchData(page, size, title, callBacks) {
    this.request({
      url: '/index',
      data: {
        page: page,
        size: size,
        title: title
      },
      callback: function (res) {
        if (res.status === 1) {
          typeof callBacks === 'function' ? callBacks(res.data) : '';
        }

      }
    })
  }
  getCollectionsData(page,size,id,callBacks) {
    this.request({
      url: '/index',
      data: {
        page: page,
        size: size,
        id: id
      },
      callback: function (res) {
        if (res.status === 1) {
          typeof callBacks === 'function' ? callBacks(res.data) : '';
        }

      }
    })
  }
  getIndexData(page,size,catid,callBacks) {
    if(catid === -1) {
      catid = 0;
    }
    this.request({
      url: '/index',
      data: {
        page: page,
        size: size,
        catid: catid
      },
      callback: function (res) {
        if(res.status === 1) {
          typeof callBacks === 'function' ? callBacks(res.data) : '';
        } 
        
      }
    })
  }
}
export default Home